#if !defined(ximera_graphics_ogre_graphicssystem_hpp)
#define ximera_graphics_ogre_graphicssystem_hpp

// -----------------------------------------------------------

#include <ximera/graphics/igraphicssystem.hpp>
#include <ximera/system/application.hpp>
#include <ximera/graphics/ogre/ogre.hpp>

#include <OgreRoot.h>
#include <OgreRenderSystem.h>
#include <OgreRenderWindow.h>
#include <OgreSceneManager.h>

namespace ximera { namespace graphics { namespace ogre 
{
    class XIMERA_PLUGIN_API GraphicsSystem : public graphics::IGraphicsSystem
    {
    public:
        GraphicsSystem(system::Application& app);

        virtual IWorld* createWorld();
        virtual void render();

        virtual void ambientLight(math::Color const& color);

        virtual void skyDome(String const& materialName);
        virtual bool isSkyDomeEnabled() const;
        virtual void disableSkyDome();

        virtual void skyBox(String const& materialName);
        virtual bool isSkyBoxEnabled() const;
        virtual void disableSkyBox();

        system::Application& application() { return _application; }

        Ogre::Root* ogreRoot() const { return _ogreRoot.get(); }
        Ogre::RenderSystem* ogreRenderSystem() const { return _ogreRenderSystem; }
        Ogre::RenderWindow* ogreWindow() const { return _ogreWindow; }
        Ogre::SceneManager* ogreSceneManager() const { return _ogreSceneManager; }

    private:
        system::Application& _application;

        SharedPtr<Ogre::Root> _ogreRoot;
        Ogre::RenderSystem* _ogreRenderSystem;
        Ogre::RenderWindow* _ogreWindow;
        Ogre::SceneManager* _ogreSceneManager;

    private:
        void setupResources();
        void setupRenderer();
        void chooseSceneManager();
        void initWindow();
        void loadResources();
    };
}}}

// -----------------------------------------------------------

#endif